What is is-glob?
The is-glob npm package is used to determine if a string is a glob pattern. A glob pattern is a string that defines a pattern for matching file names, typically used for file searching and manipulation. The package provides a simple API to check if a string contains characters that make it a valid glob pattern.
What are is-glob's main functionalities?
Check if a string is a glob pattern
This feature allows you to check if a given string is a glob pattern. It returns true if the string contains special characters like '*', '?', or '[...]' that are used in glob patterns, and false otherwise.
const isGlob = require('is-glob');
console.log(isGlob('*.js')); // true
console.log(isGlob('hello.txt')); // false
Check if an array contains a glob pattern
This feature checks if any element in an array is a glob pattern. It returns true if at least one element is a glob pattern, and false if none are.
const isGlob = require('is-glob');
console.log(isGlob(['css', '*.js'])); // true
console.log(isGlob(['css', 'js'])); // false
Other packages similar to is-glob
micromatch
Micromatch is a powerful, high-performance library for matching strings with glob patterns. It is more feature-rich than is-glob, providing advanced pattern matching, filtering, and conversion capabilities.
minimatch
Minimatch is a minimal matching utility that implements the same glob pattern matching rules as used by npm. It is similar to is-glob but also includes the ability to match patterns against strings, not just check if a string is a glob.
globby
Globby is a user-friendly glob matching utility built on top of micromatch. It extends the basic functionality of is-glob by providing methods to find files and directories in the file system using glob patterns.
node-glob
Node-glob is a full-featured glob library that can match strings against patterns and also find files in the filesystem that match a given glob. It is more comprehensive than is-glob, which only checks if a string is a glob pattern.
is-glob
Returns true
if the given string looks like a glob pattern.
Install with npm
npm i is-glob --save
Usage
var isGlob = require('is-glob');
isGlob('foo.js');
isGlob('!foo.js');
isGlob('*.js');
isGlob('**/abc.js');
isGlob('abc/*.js');
isGlob('abc/(aaa|bbb).js');
isGlob('abc/[a-z].js');
isGlob('abc/{a,b}.js');
isGlob('abc/?.js');
isGlob('abc.js');
isGlob('abc/def/ghi.js');
Related
- micromatch: Glob matching for javascript/node.js. A faster alternative to minimatch (10-45x faster on avg), with all the features you're used to using in your Grunt and gulp tasks.
- parse-glob: Parse a glob pattern into an object of tokens.
Run tests
Install dev dependencies.
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb-cli on March 04, 2015.